<template>
  <div class="activity-detail" v-if="activity">
    <h1>{{ activity.title }}</h1>
    <div class="detail-card">
      <div class="info-group">
        <label>日期：</label>
        <span>{{ activity.date }}</span>
      </div>
      <div class="info-group">
        <label>地点：</label>
        <span>{{ activity.location }}</span>
      </div>
      <div class="description">
        <h3>活动描述</h3>
        <p>{{ activity.description }}</p>
      </div>
    </div>
    <div class="actions">
      <router-link to="/public-activities" class="back-button">返回列表</router-link>
    </div>
  </div>
  <div v-else class="not-found">
    <h2>未找到活动</h2>
    <router-link to="/public-activities" class="back-button">返回列表</router-link>
  </div>
</template>

<script>
import activities from '@/data/activities.json'

export default {
  name: 'ActivityDetailView',
  data() {
    return {
      activity: null
    }
  },
  created() {
    const activityId = parseInt(this.$route.params.id)
    this.activity = activities.find(a => a.id === activityId)
  }
}
</script>

<style scoped>
.activity-detail {
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
}

.detail-card {
  background-color: white;
  border-radius: 8px;
  padding: 20px;
  margin-top: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.info-group {
  margin-bottom: 15px;
}

.info-group label {
  font-weight: bold;
  margin-right: 10px;
  color: #666;
}

.description {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.description h3 {
  margin-top: 0;
  color: #2c3e50;
}

.actions {
  margin-top: 20px;
  text-align: center;
}

.back-button {
  display: inline-block;
  padding: 10px 20px;
  background-color: #42b983;
  color: white;
  text-decoration: none;
  border-radius: 4px;
  transition: background-color 0.3s;
}

.back-button:hover {
  background-color: #3aa876;
}

.not-found {
  text-align: center;
  padding: 40px;
}
</style> 